import requests
from bs4 import BeautifulSoup
import re

urls = (
    'http://runrundouhua.com/index.php/vod/play/id/87805/sid/2/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/87806/sid/2/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/87807/sid/2/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/88269/sid/2/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/87778/sid/2/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/88817/sid/2/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/28124/sid/1/nid/1.html',
    'http://runrundouhua.com/index.php/vod/play/id/38738/sid/1/nid/1.html'
)


def get(url):
    resp = requests.get(url, timeout=30)
    bsobj = BeautifulSoup(resp.content, 'lxml')
    return bsobj


if __name__ == '__main__':
    for url in urls:
        bsobj = get(url)
        if (bsobj != None):
            a_list = bsobj.select('.cat_pos_l')
            name = '';
            if len(a_list) > 0:
                name = a_list[0].text.replace('\n','').replace(' ','').replace('在线点播','').split('>')[-1]
                # print(a_list[0].text)
            print(name)
            text = str(bsobj.html)

            port = re.findall('https:\S+\.m3u8', text)
            for s in port:
                print(s.replace('\/', '/'))

        print('==============================')
